<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-08-01 16:41
 *
 * Version: 2.0
 */

namespace App\Modules\Service\Criterias;


use Flower\Core\Repository\Contracts\CriteriaInterface;
use Flower\Core\Repository\Contracts\RepositoryInterface;

class BarberRoyaltySetCriteria implements CriteriaInterface
{

	private $storeId;
	private $userId;

	public function __construct($storeId,$userId)
	{
		$this->storeId = $storeId;
		$this->userId = $userId;
	}

	public function apply($model, RepositoryInterface $repository)
	{
		$userId = $this->userId;
		return $model
			->whereHas('userRoyalty',function($v)use($userId){
				$v->where('user_id','=',$userId);
			})
			->where('store_id','=',$this->storeId);
	}
}